package core.runner;

import java.util.EmptyStackException;

import ui.starterdecision.EndMessage;

import core.startdecision.UserStartDecision;

public class ApplicationRunner implements Runnable_Interface, 
UserDecidable_Interface
{
	
	public boolean decision;
	private boolean userDecision;
	@Override
	public void run() {
		try {
			do {
				decision = getSoftwareStartDecisionFromUser();
			}while(decision == false);
		}
		catch(NullPointerException exception){
			System.err.println("I'm sorry. It isn't OK. You must contact to author: astolarski@lgbs.pl. Error type: can't software start");
			throw new NullPointerException();
		}
		finally {
			EndMessage endMessage = new EndMessage();
			endMessage.getMessage();
		}
		
	}
	@Override
	public boolean getSoftwareStartDecisionFromUser() {
		try {
			UserStartDecision userStartDecision = new UserStartDecision();
			userDecision = userStartDecision.run();
		}
		catch(NullPointerException exception){
			System.err.println("I'm sorry. It isn't OK. You must contact to author: astolarski@lgbs.pl. Error type: couldn't load software start functionality.");
			throw new ClassNotFoundException();
		}
		finally {
			return userDecision;
		}
	}

}
